package com.itheima.d6_singleInstance;

public class Wife2 {
    private String name;

    //2 定义一个当前类型的静态变量，并私有化
    private static Wife2 wife2;
    //1.将构造方法私有化
    private Wife2() {
        name = "wwww";
    }
    //3.定义一个静态方法用来返回当前实例
    public static Wife2 getWife2() {
        if (wife2 == null) {
            wife2 = new Wife2();
        }
        return wife2;
    }

}
